<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>银行项目 | MXY 1.0版Python整理</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../home/12.Python实战项目/4.简单的登录注册.html" />
    
    
    <link rel="prev" href="../../home/12.Python实战项目/2.自动售货机.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="12.3"
        data-chapter-title="银行项目"
        data-filepath="home/12.Python实战项目/3.银行项目.md"
        data-basepath="../.."
        data-revision="Mon Oct 22 2018 08:32:35 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        MXY整理版Python基础
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" >
            
            <span><b>1.</b> Python的安装和简介</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="home/1.Python的安装和简介/1.python基础知识.html">
            
                
                    <a href="../../home/1.Python的安装和简介/1.python基础知识.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        Python的基础知识
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="home/1.Python的安装和简介/2.python的安装及版本检测.html">
            
                
                    <a href="../../home/1.Python的安装和简介/2.python的安装及版本检测.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        Python安装及版本检测
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="home/1.Python的安装和简介/3.第一个python程序.html">
            
                
                    <a href="../../home/1.Python的安装和简介/3.第一个python程序.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        第一个Python程序
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" >
            
            <span><b>2.</b> Python的基本语法</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="home/2.Python的基本语法/1.注释及语句分类.html">
            
                
                    <a href="../../home/2.Python的基本语法/1.注释及语句分类.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        注释及语句分类
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="home/2.Python的基本语法/2.命名方式和关键字.html">
            
                
                    <a href="../../home/2.Python的基本语法/2.命名方式和关键字.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        命名方式和关键字
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" >
            
            <span><b>3.</b> Python的变量及数据类型</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="home/3.变量和数据类型/1.变量.html">
            
                
                    <a href="../../home/3.变量和数据类型/1.变量.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        变量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="home/3.变量和数据类型/2.数据类型.html">
            
                
                    <a href="../../home/3.变量和数据类型/2.数据类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="home/3.变量和数据类型/3.数据类型转换.html">
            
                
                    <a href="../../home/3.变量和数据类型/3.数据类型转换.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        数据类型转换
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="home/3.变量和数据类型/4.运算和运算符.html">
            
                
                    <a href="../../home/3.变量和数据类型/4.运算和运算符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        数据类型转换
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" >
            
            <span><b>4.</b> Python的流程控制</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="home/4.流程控制/1.顺序结构和分支结构.html">
            
                
                    <a href="../../home/4.流程控制/1.顺序结构和分支结构.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        顺序结构和分支结构
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="home/4.流程控制/2.循环结构.html">
            
                
                    <a href="../../home/4.流程控制/2.循环结构.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        循环结构
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" >
            
            <span><b>5.</b> 函数及作用域</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="home/5.函数及作用域/1.函数.html">
            
                
                    <a href="../../home/5.函数及作用域/1.函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="home/5.函数及作用域/2.函数文档.html">
            
                
                    <a href="../../home/5.函数及作用域/2.函数文档.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        函数文档
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="home/5.函数及作用域/3.变量的作用域.html">
            
                
                    <a href="../../home/5.函数及作用域/3.变量的作用域.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        变量的作用域
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="home/5.函数及作用域/4.内部函数和闭包操作.html">
            
                
                    <a href="../../home/5.函数及作用域/4.内部函数和闭包操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        内部函数和闭包操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="home/5.函数及作用域/5.lambda表达式.html">
            
                
                    <a href="../../home/5.函数及作用域/5.lambda表达式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        lambda表达式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="home/5.函数及作用域/6.高阶函数.html">
            
                
                    <a href="../../home/5.函数及作用域/6.高阶函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        高阶函数
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" >
            
            <span><b>6.</b> 内置函数及操作</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="home/6.内置函数及操作/1.字符串相关.html">
            
                
                    <a href="../../home/6.内置函数及操作/1.字符串相关.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        字符串相关
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="home/6.内置函数及操作/2.format格式字符串.html">
            
                
                    <a href="../../home/6.内置函数及操作/2.format格式字符串.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        format格式字符串
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="home/6.内置函数及操作/3.内建函数.html">
            
                
                    <a href="../../home/6.内置函数及操作/3.内建函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        内建函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="home/6.内置函数及操作/4.列表.html">
            
                
                    <a href="../../home/6.内置函数及操作/4.列表.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        列表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="home/6.内置函数及操作/5.元组.html">
            
                
                    <a href="../../home/6.内置函数及操作/5.元组.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        元组
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="home/6.内置函数及操作/6.字典.html">
            
                
                    <a href="../../home/6.内置函数及操作/6.字典.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        字典
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="home/6.内置函数及操作/7.集合.html">
            
                
                    <a href="../../home/6.内置函数及操作/7.集合.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        集合
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="home/6.内置函数及操作/8.文件操作.html">
            
                
                    <a href="../../home/6.内置函数及操作/8.文件操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        文件操作
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" >
            
            <span><b>7.</b> 常用的模块</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="home/7.常用模块/1.String模块.html">
            
                
                    <a href="../../home/7.常用模块/1.String模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        String模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="home/7.常用模块/2.math模块.html">
            
                
                    <a href="../../home/7.常用模块/2.math模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        math模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="home/7.常用模块/3.OS模块.html">
            
                
                    <a href="../../home/7.常用模块/3.OS模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        OS模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="home/7.常用模块/4.zipfile模块.html">
            
                
                    <a href="../../home/7.常用模块/4.zipfile模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.</b>
                        
                        zipfile模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="home/7.常用模块/5.tarfile模块.html">
            
                
                    <a href="../../home/7.常用模块/5.tarfile模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.</b>
                        
                        tarfile模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="home/7.常用模块/6.shutil模块.html">
            
                
                    <a href="../../home/7.常用模块/6.shutil模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.</b>
                        
                        shutil模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7" data-path="home/7.常用模块/7.时间相关模块.html">
            
                
                    <a href="../../home/7.常用模块/7.时间相关模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.</b>
                        
                        时间相关模块
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" >
            
            <span><b>8.</b> 面向对象</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="home/8.面向对象/1.类和对象-上.html">
            
                
                    <a href="../../home/8.面向对象/1.类和对象-上.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        类和对象-上
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="home/8.面向对象/2.类和对象-下.html">
            
                
                    <a href="../../home/8.面向对象/2.类和对象-下.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        类和对象-下
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="home/8.面向对象/3.魔术方法.html">
            
                
                    <a href="../../home/8.面向对象/3.魔术方法.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        魔术方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="home/8.面向对象/4.装饰器.html">
            
                
                    <a href="../../home/8.面向对象/4.装饰器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        装饰器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="home/8.面向对象/5.抽象类.html">
            
                
                    <a href="../../home/8.面向对象/5.抽象类.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        抽象类
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="home/8.面向对象/6.错误和异常处理.html">
            
                
                    <a href="../../home/8.面向对象/6.错误和异常处理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        错误和异常处理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.7" data-path="home/8.面向对象/7.模块和包.html">
            
                
                    <a href="../../home/8.面向对象/7.模块和包.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.7.</b>
                        
                        模块和包
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="9" >
            
            <span><b>9.</b> tkinter模块</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="9.1" data-path="home/9.tkinter模块/tkinter模块.html">
            
                
                    <a href="../../home/9.tkinter模块/tkinter模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.1.</b>
                        
                        tkinter模块
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10" data-path="home/10.网络编程/1.网络编程.html">
            
                
                    <a href="../../home/10.网络编程/1.网络编程.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                        网络编程
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.1" data-path="home/10.网络编程/2.TCP编程.html">
            
                
                    <a href="../../home/10.网络编程/2.TCP编程.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.1.</b>
                        
                        TCP编程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.2" data-path="home/10.网络编程/3.UDP编程.html">
            
                
                    <a href="../../home/10.网络编程/3.UDP编程.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.2.</b>
                        
                        UDP编程
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="11" data-path="home/11.多任务/多任务原理.html">
            
                
                    <a href="../../home/11.多任务/多任务原理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>11.</b>
                        
                        多任务
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="11.1" data-path="home/11.多任务/1.多进程实现多任务.html">
            
                
                    <a href="../../home/11.多任务/1.多进程实现多任务.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>11.1.</b>
                        
                        多进程实现多任务
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="11.2" data-path="home/11.多任务/2.多线程实现多任务.html">
            
                
                    <a href="../../home/11.多任务/2.多线程实现多任务.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>11.2.</b>
                        
                        多线程实现多任务
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="11.3" data-path="home/11.多任务/3.协程实现多任务.html">
            
                
                    <a href="../../home/11.多任务/3.协程实现多任务.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>11.3.</b>
                        
                        协程实现多任务
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="12" >
            
            <span><b>12.</b> Python实战项目</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="12.1" data-path="home/12.Python实战项目/1.简易计算器.html">
            
                
                    <a href="../../home/12.Python实战项目/1.简易计算器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.1.</b>
                        
                        简易计算器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.2" data-path="home/12.Python实战项目/2.自动售货机.html">
            
                
                    <a href="../../home/12.Python实战项目/2.自动售货机.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.2.</b>
                        
                        自动售货机
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="12.3" data-path="home/12.Python实战项目/3.银行项目.html">
            
                
                    <a href="../../home/12.Python实战项目/3.银行项目.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.3.</b>
                        
                        银行项目
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.4" data-path="home/12.Python实战项目/4.简单的登录注册.html">
            
                
                    <a href="../../home/12.Python实战项目/4.简单的登录注册.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.4.</b>
                        
                        简单的登录注册
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.5" data-path="home/12.Python实战项目/5.双色球.html">
            
                
                    <a href="../../home/12.Python实战项目/5.双色球.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.5.</b>
                        
                        双色球
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.6" data-path="home/12.Python实战项目/6.python垃圾回收机制.html">
            
                
                    <a href="../../home/12.Python实战项目/6.python垃圾回收机制.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.6.</b>
                        
                        python垃圾回收机制
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.7" data-path="home/12.Python实战项目/7.turtle画国旗.html">
            
                
                    <a href="../../home/12.Python实战项目/7.turtle画国旗.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.7.</b>
                        
                        turtle画国旗
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.8" data-path="home/12.Python实战项目/8.turtle画小猪佩奇.html">
            
                
                    <a href="../../home/12.Python实战项目/8.turtle画小猪佩奇.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.8.</b>
                        
                        turtle画小猪佩奇
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="12.9" data-path="home/12.Python实战项目/9.turtle画个表.html">
            
                
                    <a href="../../home/12.Python实战项目/9.turtle画个表.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>12.9.</b>
                        
                        turtle画个表
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >MXY 1.0版Python整理</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x94F6;&#x884C;&#x9879;&#x76EE;">&#x94F6;&#x884C;&#x9879;&#x76EE;</h1>
<hr>
<ul>
<li><h2 id="viewpy">view.py</h2>
<pre><code class="lang-py">  <span class="hljs-comment"># -*- coding:utf-8 -*-</span>

  <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">View</span>:</span>

      <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">login</span><span class="hljs-params">(self)</span>:</span>
          name = input(<span class="hljs-string">&apos;&#x8BF7;&#x8F93;&#x5165;&#x7BA1;&#x7406;&#x5458;&#x8D26;&#x53F7;&#xFF1A;&apos;</span>)
          pwd = input(<span class="hljs-string">&apos;&#x8BF7;&#x8F93;&#x5165;&#x5BC6;&#x7801;&#xFF1A;&apos;</span>)
          <span class="hljs-keyword">if</span> name == <span class="hljs-string">&quot;admin&quot;</span> <span class="hljs-keyword">and</span> pwd == <span class="hljs-string">&quot;123456&quot;</span>:
              <span class="hljs-keyword">return</span> <span class="hljs-keyword">True</span>
          <span class="hljs-keyword">else</span>:
              <span class="hljs-keyword">return</span> <span class="hljs-keyword">False</span>

      <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">login_welcome</span><span class="hljs-params">(self)</span>:</span>
          print(<span class="hljs-string">&apos;*****************************************&apos;</span>)
          print(<span class="hljs-string">&apos;*                                       *&apos;</span>)
          print(<span class="hljs-string">&apos;*         Welcome to BS4 bank!          *&apos;</span>)
          print(<span class="hljs-string">&apos;*                                       *&apos;</span>)
          print(<span class="hljs-string">&apos;*****************************************&apos;</span>)

      <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">login_operation</span><span class="hljs-params">(self)</span>:</span>
          print(<span class="hljs-string">&apos;*****************************************&apos;</span>)
          print(<span class="hljs-string">&apos;*       Open  (1)      Sear  (2)        *&apos;</span>)
          print(<span class="hljs-string">&apos;*       Save  (3)      Take  (4)        *&apos;</span>)
          print(<span class="hljs-string">&apos;*       Tran  (5)      Chan  (6)        *&apos;</span>)
          print(<span class="hljs-string">&apos;*       Lost  (7)      Unlock(8)        *&apos;</span>)
          print(<span class="hljs-string">&apos;*                                       *&apos;</span>)
          print(<span class="hljs-string">&apos;*              EXIT  (9)                *&apos;</span>)
          print(<span class="hljs-string">&apos;*****************************************&apos;</span>)
</code></pre>
</li>
</ul>
<ul>
<li><h2 id="personpy">person.py</h2>
<pre><code class="lang-py">  <span class="hljs-comment"># -*- coding:utf-8 -*-</span>

  <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Person</span>:</span>
      <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, name, id_card, card)</span>:</span>
          self.name = name
          self.id_card = id_card
          self.card = card
</code></pre>
</li>
<li><h2 id="operationpy">operation.py</h2>
</li>
</ul>
<pre><code class="lang-py">
<span class="hljs-comment"># -*- coding:utf-8 -*-</span>

<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">import</span> pickle
<span class="hljs-keyword">import</span> random

<span class="hljs-keyword">from</span> Bank.Bank05.person <span class="hljs-keyword">import</span> Person

<span class="hljs-keyword">from</span> Bank.Bank05.card <span class="hljs-keyword">import</span> Card


<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Operation</span>:</span>
    <span class="hljs-comment"># &#x521D;&#x59CB;&#x5316;&#x52A0;&#x8F7D;&#x7528;&#x6237;&#x4FE1;&#x606F;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self)</span>:</span>
        self.get_user_dict()
        print(self.user_dict)

    <span class="hljs-comment"># &#x83B7;&#x53D6;&#x7528;&#x6237;&#x4FE1;&#x606F;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_user_dict</span><span class="hljs-params">(self)</span>:</span>
        <span class="hljs-keyword">if</span> os.path.exists(<span class="hljs-string">&quot;user.txt&quot;</span>):
            <span class="hljs-keyword">with</span> open(<span class="hljs-string">&quot;user.txt&quot;</span>, <span class="hljs-string">&quot;rb&quot;</span>) <span class="hljs-keyword">as</span> f:
                self.user_dict = pickle.load(f)
        <span class="hljs-keyword">else</span>:
            self.user_dict = {}

    <span class="hljs-comment"># &#x9000;&#x51FA;&#x94F6;&#x884C;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">exit_bank</span><span class="hljs-params">(self)</span>:</span>
        <span class="hljs-keyword">with</span> open(<span class="hljs-string">&quot;user.txt&quot;</span>, <span class="hljs-string">&quot;wb&quot;</span>) <span class="hljs-keyword">as</span> f:
            pickle.dump(self.user_dict, f)

    <span class="hljs-comment"># &#x5F00;&#x6237;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">register</span><span class="hljs-params">(self)</span>:</span>
        name = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x59D3;&#x540D;&#xFF1A;&quot;</span>)
        pwd = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x5BC6;&#x7801;&#xFF1A;&quot;</span>)
        pwd1 = input(<span class="hljs-string">&quot;&#x8BF7;&#x518D;&#x6B21;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x5BC6;&#x7801;&#xFF1A;&quot;</span>)
        <span class="hljs-keyword">if</span> pwd == pwd1:
            pwd2 = pwd
        <span class="hljs-keyword">else</span>:
            print(<span class="hljs-string">&quot;&#x60A8;&#x4E24;&#x6B21;&#x8F93;&#x5165;&#x5BC6;&#x7801;&#x4E0D;&#x4E00;&#x81F4;&#xFF01;&#x5F00;&#x6237;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>
        phone = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x624B;&#x673A;&#x53F7;&#x7801;&#xFF1A;&quot;</span>)
        id_card = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x8EAB;&#x4EFD;&#x8BC1;&#xFF1A;&quot;</span>)
        card_id = self.get_card_id()
        <span class="hljs-comment"># &#x5B9E;&#x4F8B;&#x5316;&#x5361;&#x548C;&#x4EBA;</span>
        card = Card(card_id, pwd2, <span class="hljs-number">10</span>)
        user = Person(name, id_card, card)
        <span class="hljs-comment"># &#x5C06;&#x6CE8;&#x518C;&#x7684;&#x4FE1;&#x606F;&#x5B58;&#x5165;&#x5B57;&#x5178;</span>
        self.user_dict[card_id] = user
        print(<span class="hljs-string">&quot;&#x606D;&#x559C;&#x60A8;&#xFF0C;%s&#xFF0C;&#x6CE8;&#x518C;&#x6210;&#x529F;&#xFF01;&#x60A8;&#x7684;&#x5361;&#x53F7;&#x4E3A;&#xFF1A;%s&#xFF0C;&#x5361;&#x5185;&#x4F59;&#x989D;&#xFF1A;%s&#x3002;&#xFF08;&#x8BF7;&#x7262;&#x8BB0;&#x60A8;&#x7684;&#x5361;&#x53F7;&#xFF01;&#xFF09;&quot;</span> % (user.name, card.card_id, card.money))

    <span class="hljs-comment"># &#x67E5;&#x8BE2;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">query</span><span class="hljs-params">(self)</span>:</span>
        user = self.get_user_info()
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user:
            print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x4E0D;&#x5B58;&#x5728;&#xFF01;&#x67E5;&#x8BE2;&#x5931;&#x8D25;...&quot;</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">if</span> user.card.islock:
                print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&#x67E5;&#x8BE2;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">else</span>:
                check = self.check_password(user)
                <span class="hljs-keyword">if</span> check:
                    print(<span class="hljs-string">&quot;&#x5361;&#x5185;&#x4F59;&#x989D;&#xFF1A;%s&quot;</span> % (user.card.money))
                <span class="hljs-keyword">else</span>:
                    user.card.islock = <span class="hljs-keyword">True</span>
                    print(<span class="hljs-string">&quot;&#x5BC6;&#x7801;&#x8FDE;&#x7EED;&#x8F93;&#x5165;&#x9519;&#x8BEF;3&#x6B21;&#xFF0C;&#x5361;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&quot;</span>)

    <span class="hljs-comment"># &#x5B58;&#x94B1;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">save_money</span><span class="hljs-params">(self)</span>:</span>
        user = self.get_user_info()
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user:
            print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x4E0D;&#x5B58;&#x5728;&#xFF01;&#x5B58;&#x94B1;&#x5931;&#x8D25;...&quot;</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">if</span> user.card.islock:
                print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&#x5B58;&#x94B1;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">else</span>:
                check = self.check_password(user)
                <span class="hljs-keyword">if</span> check:
                    new_money = int(input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x60F3;&#x5B58;&#x5165;&#x7684;&#x91D1;&#x989D;&#xFF1A;&quot;</span>))
                    <span class="hljs-keyword">if</span> new_money &lt; <span class="hljs-number">0</span>:
                        print(<span class="hljs-string">&quot;&#x60A8;&#x8F93;&#x5165;&#x7684;&#x91D1;&#x989D;&#x9519;&#x8BEF;&#xFF0C;&#x5B58;&#x94B1;&#x5931;&#x8D25;...&quot;</span>)
                    <span class="hljs-keyword">else</span>:
                        user.card.money += new_money
                        print(<span class="hljs-string">&quot;&#x606D;&#x559C;&#x60A8;&#xFF0C;&#x5B58;&#x94B1;&#x6210;&#x529F;&#xFF01;&#x5361;&#x5185;&#x4F59;&#x989D;&#xFF1A;%s.&quot;</span> % (user.card.money))
                <span class="hljs-keyword">else</span>:
                    user.card.islock = <span class="hljs-keyword">True</span>
                    print(<span class="hljs-string">&quot;&#x5BC6;&#x7801;&#x8FDE;&#x7EED;&#x8F93;&#x5165;&#x9519;&#x8BEF;3&#x6B21;&#xFF0C;&#x5B58;&#x94B1;&#x5931;&#x8D25;&#xFF0C;&#x5361;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&quot;</span>)

    <span class="hljs-comment"># &#x53D6;&#x94B1;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_money</span><span class="hljs-params">(self)</span>:</span>
        user = self.get_user_info()
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user:
            print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x4E0D;&#x5B58;&#x5728;&#xFF01;&#x53D6;&#x6B3E;&#x5931;&#x8D25;...&quot;</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">if</span> user.card.islock:
                print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&#x53D6;&#x6B3E;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">else</span>:
                check = self.check_password(user)
                <span class="hljs-keyword">if</span> check:
                    new_money = int(input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x60F3;&#x53D6;&#x51FA;&#x7684;&#x91D1;&#x989D;&#xFF1A;&quot;</span>))
                    <span class="hljs-keyword">if</span> <span class="hljs-number">0</span> &lt; new_money &lt; user.card.money:
                        user.card.money -= new_money
                        print(<span class="hljs-string">&quot;&#x606D;&#x559C;&#x60A8;&#xFF0C;&#x53D6;&#x6B3E;&#x6210;&#x529F;&#xFF01;&#x5361;&#x5185;&#x4F59;&#x989D;&#xFF1A;%s.&quot;</span> % (user.card.money))
                    <span class="hljs-keyword">else</span>:
                        print(<span class="hljs-string">&quot;&#x60A8;&#x8F93;&#x5165;&#x7684;&#x91D1;&#x989D;&#x9519;&#x8BEF;&#xFF0C;&#x53D6;&#x6B3E;&#x5931;&#x8D25;...&quot;</span>)
                <span class="hljs-keyword">else</span>:
                    user.card.islock = <span class="hljs-keyword">True</span>
                    print(<span class="hljs-string">&quot;&#x5BC6;&#x7801;&#x8FDE;&#x7EED;&#x8F93;&#x5165;&#x9519;&#x8BEF;3&#x6B21;&#xFF0C;&#x53D6;&#x6B3E;&#x5931;&#x8D25;&#xFF0C;&#x5361;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&quot;</span>)

    <span class="hljs-comment"># &#x8F6C;&#x8D26;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">transfer_money</span><span class="hljs-params">(self)</span>:</span>
        card_id1 = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x60F3;&#x8F6C;&#x5165;&#x7684;&#x5361;&#x53F7;&#xFF1A;&quot;</span>)
        user1 = self.user_dict[card_id1]
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user1:
            print(<span class="hljs-string">&quot;&#x8F6C;&#x5165;&#x5361;&#x53F7;&#x4E0D;&#x5B58;&#x5728;&#xFF01;&#x8F6C;&#x8D26;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>
        <span class="hljs-keyword">if</span> user1.card.islock:
            print(<span class="hljs-string">&quot;&#x8F6C;&#x5165;&#x5361;&#x53F7;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&#x8F6C;&#x8D26;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>

        card_id = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x5361;&#x53F7;&#xFF1A;&quot;</span>)
        user = self.user_dict[card_id]
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user:
            print(<span class="hljs-string">&quot;&#x60A8;&#x7684;&#x5361;&#x53F7;&#x4E0D;&#x5B58;&#x5728;&#xFF01;&#x8F6C;&#x8D26;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>
        <span class="hljs-keyword">if</span> user.card.islock:
            print(<span class="hljs-string">&quot;&#x4F60;&#x7684;&#x5361;&#x53F7;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&#x8F6C;&#x8D26;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>

        check = self.check_password(user)
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> check:
            print(<span class="hljs-string">&quot;&#x60A8;&#x8F93;&#x5165;&#x5BC6;&#x7801;&#x8FDE;&#x7EED;&#x9519;&#x8BEF;3&#x6B21;&#xFF0C;&#x8F6C;&#x8D26;&#x5931;&#x8D25;&#xFF0C;&#x5361;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&quot;</span>)
        <span class="hljs-keyword">else</span>:
            new_money = int(input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x60F3;&#x8981;&#x8F6C;&#x51FA;&#x7684;&#x91D1;&#x989D;&#xFF1A;&quot;</span>))
            <span class="hljs-keyword">if</span> new_money &lt; <span class="hljs-number">0</span>:
                print(<span class="hljs-string">&quot;&#x60A8;&#x8F93;&#x5165;&#x91D1;&#x989D;&#x6709;&#x8BEF;&#xFF0C;&#x8F6C;&#x8D26;&#x5931;&#x8D25;&#xFF01;&quot;</span>)
                <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>
            <span class="hljs-keyword">if</span> new_money &gt; user.card.money:
                print(<span class="hljs-string">&quot;&#x60A8;&#x5361;&#x5185;&#x4F59;&#x989D;&#x4E0D;&#x8DB3;&#xFF0C;&#x8F6C;&#x8D26;&#x5931;&#x8D25;&#xFF01;&quot;</span>)
                <span class="hljs-keyword">return</span> -<span class="hljs-number">1</span>
            user.card.money -= new_money
            user1.card.money += new_money
            print(<span class="hljs-string">&quot;&#x606D;&#x559C;&#x60A8;&#xFF01;&#x8F6C;&#x8D26;&#x6210;&#x529F;...&#x6B64;&#x6B21;&#x8F6C;&#x8D26;&#x91D1;&#x989D;&#xFF1A;%s&quot;</span> % (new_money))


    <span class="hljs-comment"># &#x6539;&#x5BC6;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">change_pwd</span><span class="hljs-params">(self)</span>:</span>
        user = self.get_user_info()
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user:
            print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x4E0D;&#x5B58;&#x5728;&#xFF01;&#x6539;&#x5BC6;&#x5931;&#x8D25;...&quot;</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">if</span> user.card.islock:
                print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&#x6539;&#x5BC6;&#x5931;&#x8D25;...&quot;</span>)
            <span class="hljs-keyword">else</span>:
                check = self.check_password(user)
                <span class="hljs-keyword">if</span> check:
                    new_password = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x65B0;&#x5BC6;&#x7801;&#xFF1A;&quot;</span>)
                    new_password1 = input(<span class="hljs-string">&quot;&#x8BF7;&#x518D;&#x6B21;&#x8F93;&#x5165;&#x65B0;&#x5BC6;&#x7801;&#xFF1A;&quot;</span>)
                    <span class="hljs-keyword">if</span> new_password == new_password1:
                        user.card.password = new_password
                        print(<span class="hljs-string">&quot;&#x606D;&#x559C;&#x60A8;&#xFF0C;&#x6539;&#x5BC6;&#x6210;&#x529F;&#xFF01;&quot;</span>)
                    <span class="hljs-keyword">else</span>:
                        print(<span class="hljs-string">&quot;&#x4E24;&#x6B21;&#x8F93;&#x5165;&#x5BC6;&#x7801;&#x4E0D;&#x4E00;&#x81F4;&#xFF0C;&#x6539;&#x5BC6;&#x5931;&#x8D25;&#xFF01;&quot;</span>)
                <span class="hljs-keyword">else</span>:
                    user.card.islock = <span class="hljs-keyword">True</span>
                    print(<span class="hljs-string">&quot;&#x5BC6;&#x7801;&#x8FDE;&#x7EED;&#x8F93;&#x5165;&#x9519;&#x8BEF;3&#x6B21;&#xFF0C;&#x6539;&#x5BC6;&#x5931;&#x8D25;&#xFF0C;&#x5361;&#x5DF2;&#x88AB;&#x9501;&#x5B9A;&#xFF01;&quot;</span>)

    <span class="hljs-comment"># &#x6302;&#x5931;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">lock</span><span class="hljs-params">(self)</span>:</span>
        user = self.get_user_info()
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user:
            print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x4E0D;&#x5B58;&#x5728;&#xFF01;&#x6302;&#x5931;&#x5931;&#x8D25;...&quot;</span>)
        <span class="hljs-keyword">else</span>:
            id_card = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x8EAB;&#x4EFD;&#x8BC1;&#x53F7;&#xFF1A;&quot;</span>)
            <span class="hljs-keyword">if</span> id_card == user.id_card:
                user.card.islock = <span class="hljs-keyword">True</span>
                print(<span class="hljs-string">&quot;&#x606D;&#x559C;&#x60A8;&#xFF0C;&#x6302;&#x5931;&#x6210;&#x529F;&#xFF01;&quot;</span>)
            <span class="hljs-keyword">else</span>:
                print(<span class="hljs-string">&quot;&#x8EAB;&#x4EFD;&#x8BC1;&#x8F93;&#x5165;&#x9519;&#x8BEF;&#xFF01;&#x6302;&#x5931;&#x5931;&#x8D25;&#xFF01;&quot;</span>)

    <span class="hljs-comment"># &#x89E3;&#x9501;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">unlock</span><span class="hljs-params">(self)</span>:</span>
        user = self.get_user_info()
        <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user:
            print(<span class="hljs-string">&quot;&#x5361;&#x53F7;&#x4E0D;&#x5B58;&#x5728;&#xFF01;&#x89E3;&#x9501;&#x5931;&#x8D25;...&quot;</span>)
        <span class="hljs-keyword">else</span>:
            <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> user.card.islock:
                print(<span class="hljs-string">&quot;&#x8BE5;&#x5361;&#x672A;&#x88AB;&#x9501;&#x5B9A;&#xFF0C;&#x65E0;&#x9700;&#x89E3;&#x9501;&#xFF01;&quot;</span>)
            <span class="hljs-keyword">else</span>:
                check = self.check_password(user)
                <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> check:
                    print(<span class="hljs-string">&quot;&#x5BC6;&#x7801;&#x9519;&#x8BEF;&#x4E09;&#x6B21;&#xFF0C;&#x89E3;&#x9501;&#x5931;&#x8D25;&#xFF01;&quot;</span>)
                <span class="hljs-keyword">else</span>:
                    user.card.islock = <span class="hljs-keyword">False</span>
                    print(<span class="hljs-string">&quot;&#x606D;&#x559C;&#x60A8;&#xFF0C;&#x89E3;&#x9501;&#x6210;&#x529F;&#xFF01;&quot;</span>)

    <span class="hljs-comment"># &#x968F;&#x673A;&#x83B7;&#x53D6;5&#x4F4D;&#x5361;&#x53F7;&#xFF08;&#x4E14;&#x4E0D;&#x80FD;&#x91CD;&#x590D;&#xFF09;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_card_id</span><span class="hljs-params">(self)</span>:</span>
        <span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
            card_id = str(random.randint(<span class="hljs-number">10000</span>, <span class="hljs-number">99999</span>))
            <span class="hljs-keyword">if</span> card_id <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> self.user_dict:
                <span class="hljs-keyword">return</span> card_id

    <span class="hljs-comment"># &#x83B7;&#x5F97;&#x4E00;&#x4E2A;&#x7528;&#x6237;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_user_info</span><span class="hljs-params">(self)</span>:</span>
        card_id = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x5361;&#x53F7;&#xFF1A;&quot;</span>)
        <span class="hljs-keyword">if</span> card_id <span class="hljs-keyword">not</span> <span class="hljs-keyword">in</span> self.user_dict:
            <span class="hljs-keyword">return</span> <span class="hljs-keyword">False</span>
        <span class="hljs-keyword">else</span>:
            user = self.user_dict.get(card_id)
            <span class="hljs-keyword">return</span> user

    <span class="hljs-comment"># &#x68C0;&#x67E5;&#x8F93;&#x5165;&#x5BC6;&#x7801;&#xFF0C;&#x9519;3&#x6B21;&#x9501;&#x5B9A;&#x8BE5;&#x5361;</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">check_password</span><span class="hljs-params">(self, user)</span>:</span>
        count = <span class="hljs-number">1</span>
        <span class="hljs-keyword">while</span> count &lt; <span class="hljs-number">4</span>:
            pwd = input(<span class="hljs-string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x60A8;&#x7684;&#x5BC6;&#x7801;&#xFF1A;&quot;</span>)
            <span class="hljs-keyword">if</span> pwd == user.card.password:
                <span class="hljs-keyword">return</span> <span class="hljs-keyword">True</span>
            count += <span class="hljs-number">1</span>
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">False</span>
</code></pre>
<ul>
<li><h2 id="cardpy">card.py</h2>
<pre><code class="lang-py">  <span class="hljs-comment"># -*- coding:utf-8 -*-</span>

  <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Card</span>:</span>
      <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, card_id, password, money)</span>:</span>
          self.card_id = card_id
          self.password = password
          self.money = money
          self.islock = <span class="hljs-keyword">False</span>
</code></pre>
</li>
<li><h2 id="mainpy">main.py</h2>
<pre><code class="lang-py">  <span class="hljs-comment"># -*- coding:utf-8 -*-</span>

  <span class="hljs-keyword">import</span> time

  <span class="hljs-keyword">from</span> Bank.Bank05.operation <span class="hljs-keyword">import</span> Operation
  <span class="hljs-keyword">from</span> Bank.Bank05.view <span class="hljs-keyword">import</span> View

  v = View()

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>:</span>
      <span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
          <span class="hljs-keyword">if</span> v.login():
              v.login_welcome()
              print(<span class="hljs-string">&apos;&#x767B;&#x9646;&#x6210;&#x529F;&#xFF01;&#x8BF7;&#x7A0D;&#x540E;...&apos;</span>)
              <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(<span class="hljs-number">3</span>):
                  print(<span class="hljs-string">&apos;*&apos;</span> * (<span class="hljs-number">3</span> - i))
                  time.sleep(<span class="hljs-number">1</span>)
              o = Operation()
              <span class="hljs-keyword">break</span>
          <span class="hljs-keyword">else</span>:
              print(<span class="hljs-string">&quot;&#x8D26;&#x53F7;&#x6216;&#x5BC6;&#x7801;&#x8F93;&#x5165;&#x9519;&#x8BEF;&#xFF01;&quot;</span>)
      <span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
          <span class="hljs-keyword">try</span>:
              v.login_operation()
              choice = input(<span class="hljs-string">&quot;&#x8BF7;&#x9009;&#x62E9;&#x60A8;&#x60F3;&#x8981;&#x8FDB;&#x884C;&#x7684;&#x670D;&#x52A1;&#xFF1A;&quot;</span>)
              <span class="hljs-comment"># &#x5F00;&#x6237;</span>
              <span class="hljs-keyword">if</span> choice == <span class="hljs-string">&apos;1&apos;</span>:
                  o.register()

              <span class="hljs-comment"># &#x67E5;&#x8BE2;</span>
              <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">&apos;2&apos;</span>:
                  o.query()

              <span class="hljs-comment"># &#x5B58;&#x94B1;</span>
              <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">&apos;3&apos;</span>:
                  o.save_money()

              <span class="hljs-comment"># &#x53D6;&#x94B1;</span>
              <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">&apos;4&apos;</span>:
                  o.get_money()

              <span class="hljs-comment"># &#x8F6C;&#x8D26;</span>
              <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">&apos;5&apos;</span>:
                  o.transfer_money()

              <span class="hljs-comment"># &#x6539;&#x5BC6;</span>
              <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">&apos;6&apos;</span>:
                  o.change_pwd()

              <span class="hljs-comment"># &#x6302;&#x5931;</span>
              <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">&apos;7&apos;</span>:
                  o.lock()

              <span class="hljs-comment"># &#x89E3;&#x9501;</span>
              <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">&apos;8&apos;</span>:
                  o.unlock()

              <span class="hljs-comment"># &#x9000;&#x51FA;</span>
              <span class="hljs-keyword">elif</span> choice == <span class="hljs-string">&apos;9&apos;</span>:
                  o.exit_bank()
                  print(<span class="hljs-string">&quot;&#x6B63;&#x5728;&#x9000;&#x51FA;&#xFF0C;&#x8BF7;&#x7A0D;&#x540E;...&quot;</span>)
                  time.sleep(<span class="hljs-number">1</span>)
                  print(<span class="hljs-string">&quot;&#x5DF2;&#x9000;&#x51FA;&#xFF01;&quot;</span>)
                  <span class="hljs-keyword">break</span>

              <span class="hljs-keyword">else</span>:
                  <span class="hljs-keyword">raise</span> Exception(<span class="hljs-string">&quot;&#x60A8;&#x8F93;&#x5165;&#x7684;&#x5E8F;&#x53F7;&#x6709;&#x8BEF;&#xFF0C;&#x8BF7;&#x91CD;&#x65B0;&#x8F93;&#x5165;&#xFF01;&quot;</span>)
              <span class="hljs-comment"># &#x6BCF;&#x6267;&#x884C;&#x4E00;&#x6B21;&#x5C31;&#x505C;&#x987F;0.5s</span>
              time.sleep(<span class="hljs-number">0.5</span>)

          <span class="hljs-keyword">except</span> BaseException <span class="hljs-keyword">as</span> e:
              print(e)
  <span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&apos;__main__&apos;</span>:
      main()
</code></pre>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../home/12.Python实战项目/2.自动售货机.html" class="navigation navigation-prev " aria-label="Previous page: 自动售货机"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../home/12.Python实战项目/4.简单的登录注册.html" class="navigation navigation-next " aria-label="Next page: 简单的登录注册"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
